package com.lxf.test.androidtest.abc;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by Administrator on 2016/2/22.
 */
public class MyDBHelper extends SQLiteOpenHelper {
    private static final String TAG = "TestSQLite";
    public static final int VERSION = 1;


    //必须要有构造函数
    public MyDBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory,
                       int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table stu_table(id int,sname varchar(20),sage int,ssex varchar(10))";
        //execSQL函数用于执行SQL语句
        //db.execSQL(sql);
        //sql = "create table ARFILE_GROUP( ID VARCHAR(32) not null,GROUPNAME VARCHAR(60),SHORTNAME VARCHAR(16))";
        sql = "create table TASKFINISH( ID VARCHAR(32) not null,employeeid VARCHAR(32),taskuid VARCHAR(32)," +
                "workdate DATE,completeqty INT, runtime1 INT, completework INT, actualwork,INT)";
        db.execSQL(sql);
    //输出创建数据库的日志信息
        Log.i(TAG, "create Database------------->");

    }

    //当更新数据库的时候执行该方法
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    //输出更新数据库的日志信息
        Log.i(TAG, "update Database------------->");
    }

}
